package com.zhijiang.common.util;


import cn.hutool.http.webservice.SoapClient;
import com.alibaba.fastjson.JSONObject;
import com.zhijiang.hospital.entrty.dto.EmployeeDto;
import com.zhijiang.hospital.entrty.dto.HisUserDto;
import org.dom4j.DocumentException;


public class HttpPost {

    private static final String url = "http://172.22.156.34:8888/SPDadjustprice.asmx";

    public static HisUserDto validateUser(EmployeeDto employeeDto){
        SoapClient soapClient = SoapClient.create(url)
                .setMethod("CheckUser", "http://tempuri.org/")
                .setParam("UserName", employeeDto.getEmplCode())
                .setParam("UserPwd", employeeDto.getPassword())
                .setConnectionTimeout(15000)
                .setReadTimeout(15000)
                .timeout(15000);
        String result = soapClient.send();
        JSONObject jsonObject = null;
        try {
            jsonObject = XmltoJsonUtil.xmlToJson(result);
        } catch (DocumentException e) {
            throw new RuntimeException(e);
        }
        return JSONObject.parseObject(jsonObject.getJSONObject("Envelope").
                getJSONObject("Body").
                getJSONObject("CheckUserResponse").toJSONString(), HisUserDto.class);
    }
}
